Fix parallel PDF API script env handling#4385
Conversation
There was a problem hiding this comment.
2 issues found across 2 files
Shadow auto-approve: would not auto-approve because issues were found.
Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Shadow auto-approve: would auto-approve. Improves shell script portability, env var handling, and validation. Low risk, no change to core logic or API endpoints.
Re-trigger cubic
|
Thanks for the quick review! I pushed a follow-up that validates BATCH_SIZE as a positive integer before the batching loop, tightens PDF_SPLIT_PAGE_SIZE to the same positive-integer shape, and checks that checksum generation produced a non-empty value before constructing split/output paths. I also verified the failure paths for BATCH_SIZE=0, non-numeric BATCH_SIZE, PDF_SPLIT_PAGE_SIZE=0, and a missing PDF input. Hopefully this addresses the concerns :) |
Summary
Fixes
scripts/user/process-pdf-parallel-through-api.shso it can be run with documented environment overrides and on the default Bash shipped with macOS.Changes:
UNST_API_KEYas required.UNST_API_ENDPOINTsupport instead of hard-coding the public endpoint.STRATEGY,BATCH_SIZE,PDF_SPLIT_PAGE_SIZE, andPDF_SPLITS_DIRdefaults before use.UNST_API_KEYis missing.mapfileusage with a Bash 3.2-compatible loop.md5sumand BSD/macOSmd5 -qin the parallel script and split helper.Validation
I tested the script against the hosted API with a valid
UNST_API_KEYusing a one-page split ofexample-docs/pdf/layout-parser-paper-fast.pdf:The script produced a valid split JSON file, combined it successfully, and the combined output contained 25 JSON elements:
I also checked the updated shell scripts with bash -n.